<?php

namespace app\api\model;

use think\Model;

/**
 * Banner
 */
class Banner extends Model
{
    // 表名
    protected $name = 'banner';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;



    public function getContentAttr($value): string
    {
        return !$value ? '' : htmlspecialchars_decode($value);
    }


    public function getBanner(){
        $list = self::where(['status' => 1])->order('weigh desc')->field('id,name,image')->select()->toArray();
        if(!$list) return api_message();
        foreach ($list as &$val){
           $val['image'] = full_url($val['image'],true);
        }
        return api_message($list);
    }
}